﻿/**
 * Create in 2012-2-6.
 */
package kit4j.ui.cs.awt.image.drawer;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import kit4j.generator.keyless.RandomColorKeylessGenerator;

/**
 * 随机颜色填充器，在指定的Image对象上随机填充某一种颜色。
 * 
 * @author MiniKnife
 *
 */
public class RandomColorFillDrawer extends AbstractDrawer implements IDrawer {
	
	private RandomColorKeylessGenerator colorGenerator;
	
	/**
	 * 创建一个随机颜色填充器。
	 */
	public RandomColorFillDrawer() {
		colorGenerator = new RandomColorKeylessGenerator();
	}

	/**
	 * @see kit4j.ui.cs.awt.image.drawer.AbstractDrawer#nextColor(java.awt.Graphics)
	 */
	@Override
	protected Color nextColor(Graphics g) {
		return colorGenerator.next();
	}

	/**
	 * @see kit4j.ui.cs.awt.image.drawer.AbstractDrawer#nextFont(java.awt.Graphics)
	 */
	@Override
	protected Font nextFont(Graphics g) {
		return g.getFont();
	}

	/**
	 * @see kit4j.ui.cs.awt.image.drawer.AbstractDrawer#nextXORColor(java.awt.Graphics)
	 */
	@Override
	protected Color nextXORColor(Graphics g) {
		return g.getColor();
	}

	/**
	 * @see kit4j.ui.cs.awt.image.drawer.AbstractDrawer#doDraw(java.awt.Image, java.awt.Graphics)
	 */
	@Override
	protected Image doDraw(Image img, Graphics g) {
		g.fillRect(0, 0, img.getWidth(null), img.getHeight(null));

		return img;
	}

}
